<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*
<span class='line'>  2</span> 	Copyright (c) 2008 Alexander MacCaw
<span class='line'>  3</span> 
<span class='line'>  4</span> 	Permission is hereby granted, free of charge, to any person obtaining
<span class='line'>  5</span> 	a copy of this software and associated documentation files (the
<span class='line'>  6</span> 	"Software"), to deal in the Software without restriction, including
<span class='line'>  7</span> 	without limitation the rights to use, copy, modify, merge, publish,
<span class='line'>  8</span> 	distribute, sublicense, and/or sell copies of the Software, and to
<span class='line'>  9</span> 	permit persons to whom the Software is furnished to do so, subject to
<span class='line'> 10</span> 	the following conditions:
<span class='line'> 11</span> 
<span class='line'> 12</span> 	The above copyright notice and this permission notice shall be
<span class='line'> 13</span> 	included in all copies or substantial portions of the Software.
<span class='line'> 14</span> 
<span class='line'> 15</span> 	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
<span class='line'> 16</span> 	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
<span class='line'> 17</span> 	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
<span class='line'> 18</span> 	NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
<span class='line'> 19</span> 	LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
<span class='line'> 20</span> 	OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
<span class='line'> 21</span> 	WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<span class='line'> 22</span> */</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="COMM">/* This variable has to be left here because Juggernaut.swf expects it. */</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">juggernaut</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 26</span> 
<span class='line'> 27</span> </span><span class="COMM">/**
<span class='line'> 28</span> 	@class
<span class='line'> 29</span> 	
<span class='line'> 30</span> 	&lt;p>Juggernaut is a utility that allows the server to initiate connections with the browser.&lt;/p>
<span class='line'> 31</span> 	&lt;p>This is what facilitates the client-server bindings that allow for automatic-collborative models.&lt;/p>
<span class='line'> 32</span> 	&lt;p>&lt;i>Note: this version of Juggernaut has been altered to work better with the rio framework.&lt;/i>&lt;/p>
<span class='line'> 33</span> */</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="NAME">rio.Juggernaut</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Class.create</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 35</span> 	</span><span class="NAME">initialize</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 36</span> 		</span><span class="NAME">this.is_connected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 37</span> 		</span><span class="NAME">this.attempting_to_reconnect</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 38</span> 		</span><span class="NAME">this.ever_been_connected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span> 		</span><span class="NAME">this.options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 40</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.options.client_id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> 
<span class='line'> 41</span> 			</span><span class="NAME">this.options.client_id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.options.session_id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 42</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 43</span> 
<span class='line'> 44</span> 		</span><span class="NAME">this.bindToWindow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> 		
<span class='line'> 46</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">connectionAttr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">rio.Attr.create</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 47</span> 			</span><span class="NAME">attrAccessors</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">[</span><span class="STRN">"live"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">]</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'> 48</span> 		</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 49</span> 		</span><span class="NAME">this.live</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">connectionAttr</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">live</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 50</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 51</span> 
<span class='line'> 52</span> 	</span><span class="NAME">logger</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">msg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 53</span> 		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.options.debug</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 54</span> 			</span><span class="NAME">msg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"Juggernaut: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" on "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.options.host</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">':'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.options.port</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 55</span> 			</span><span class="NAME">rio.log</span><span class="PUNC">(</span><span class="NAME">msg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 56</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 57</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 58</span> 
<span class='line'> 59</span> 	</span><span class="NAME">initialized</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 60</span> 		</span><span class="NAME">this.fire_event</span><span class="PUNC">(</span><span class="STRN">'initialized'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> 		</span><span class="NAME">this.connect</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 63</span> 
<span class='line'> 64</span> 	</span><span class="NAME">broadcast</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">body</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">client_ids</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">channels</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 65</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">command</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'broadcast'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">body</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">body</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="PUNC">||</span><span class="STRN">'to_channels'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 66</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">channels</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">msg.channels</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">channels</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 67</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">client_ids</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">msg.client_ids</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">client_ids</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 68</span> 		</span><span class="NAME">msg.client_id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.options.client_id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 69</span> 		</span><span class="NAME">msg.session_id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.options.session_id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> 		</span><span class="NAME">this.sendData</span><span class="PUNC">(</span><span class="NAME">this.toJSON</span><span class="PUNC">(</span><span class="NAME">msg</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 72</span> 
<span class='line'> 73</span> 	</span><span class="NAME">sendData</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 74</span> 		</span><span class="NAME">this.swf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">sendData</span><span class="PUNC">(</span><span class="NAME">escape</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 75</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 76</span> 
<span class='line'> 77</span> 	</span><span class="NAME">connect</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 78</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.is_connected</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 79</span> 			</span><span class="NAME">this.fire_event</span><span class="PUNC">(</span><span class="STRN">'connect'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> 			</span><span class="NAME">this.swf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">connect</span><span class="PUNC">(</span><span class="NAME">this.options.host</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.options.port</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 82</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 83</span> 
<span class='line'> 84</span> 	</span><span class="NAME">disconnect</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 85</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this.is_connected</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 86</span> 			</span><span class="NAME">this.swf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">disconnect</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> 			</span><span class="NAME">this.is_connected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> 			</span><span class="NAME">this.live.update</span><span class="PUNC">(</span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 90</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 91</span> 	
<span class='line'> 92</span> 	</span><span class="NAME">addChannel</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">channelName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 93</span> 		</span><span class="NAME">this.options.channels.push</span><span class="PUNC">(</span><span class="NAME">channelName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> 		</span><span class="NAME">this.resetConnection</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">	
<span class='line'> 95</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 96</span> 	
<span class='line'> 97</span> 	</span><span class="COMM">// Added to facilitate subscription to new channels</span><span class="WHIT">
<span class='line'> 98</span> 	</span><span class="NAME">resetConnection</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 99</span> 		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this._resetTask</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">this._resetTask</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">rio.DelayedTask</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>100</span> 		</span><span class="NAME">this._resetTask.delay</span><span class="PUNC">(</span><span class="NUMB">100</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>101</span> 			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">this.swf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this.swf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">connect</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> 
<span class='line'>102</span> 				</span><span class="NAME">this.resetConnection.bind</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">delay</span><span class="PUNC">(</span><span class="NUMB">500</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>103</span> 				</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> 			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>105</span> 			</span><span class="NAME">this.disconnect</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span> 			</span><span class="NAME">this.connect</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>107</span> 		</span><span class="PUNC">}</span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>109</span> 
<span class='line'>110</span> 	</span><span class="NAME">handshake</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>111</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">handshake</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> 		</span><span class="NAME">handshake.command</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'subscribe'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this.options.session_id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">handshake.session_id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.options.session_id</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>114</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this.options.client_id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">handshake.client_id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.options.client_id</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>115</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this.options.channels</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">handshake.channels</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.options.channels</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>116</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this.currentMsgId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>117</span> 			</span><span class="NAME">handshake.last_msg_id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.currentMsgId</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>118</span> 			</span><span class="NAME">handshake.signature</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.currentSignature</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>120</span> 
<span class='line'>121</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">handshake</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>123</span> 
<span class='line'>124</span> 	</span><span class="NAME">connected</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>125</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">json</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.toJSON</span><span class="PUNC">(</span><span class="NAME">this.handshake</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> 		</span><span class="NAME">this.sendData</span><span class="PUNC">(</span><span class="NAME">json</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>127</span> 		</span><span class="NAME">this.ever_been_connected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span> 		</span><span class="NAME">this.is_connected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> 		</span><span class="NAME">this.live.update</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>130</span> 		</span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>131</span> 			</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this.is_connected</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">this.attempting_to_reconnect</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>132</span> 		</span><span class="PUNC">}</span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> 		</span><span class="NAME">this.logger</span><span class="PUNC">(</span><span class="STRN">'Connected'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>134</span> 		</span><span class="NAME">this.fire_event</span><span class="PUNC">(</span><span class="STRN">'connected'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>136</span> 
<span class='line'>137</span> 	</span><span class="COMM">// OVERRIDE FOR CHAT STYLE APPS - POSSIBLE MALICIOUS CONTENT CAN BE EVALED</span><span class="WHIT">
<span class='line'>138</span> 	</span><span class="NAME">receiveData</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>139</span> 		</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">msg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.parseJSON</span><span class="PUNC">(</span><span class="NAME">unescape</span><span class="PUNC">(</span><span class="NAME">e.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> 		</span><span class="NAME">this.currentMsgId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">msg.id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> 		</span><span class="NAME">this.currentSignature</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">msg.signature</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> 		
<span class='line'>143</span> 		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">msg.body.startsWith</span><span class="PUNC">(</span><span class="STRN">"rio.console.touch"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>144</span> 			</span><span class="COMM">// don't log autospec stuff</span><span class="WHIT">
<span class='line'>145</span> 		</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>146</span> 			</span><span class="NAME">this.logger</span><span class="PUNC">(</span><span class="STRN">"Received data:\n"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">msg.body</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"\n"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>148</span> 		</span><span class="NAME">eval</span><span class="PUNC">(</span><span class="NAME">msg.body</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>149</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>150</span> 
<span class='line'>151</span> 	</span><span class="COMM">/*** START PROTOTYPE SPECIFIC - OVERRIDE FOR OTHER FRAMEWORKS ***/</span><span class="WHIT">
<span class='line'>152</span> 	</span><span class="NAME">fire_event</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">fx_name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>153</span> 		</span><span class="NAME">$</span><span class="PUNC">(</span><span class="NAME">document</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">fire</span><span class="PUNC">(</span><span class="STRN">"juggernaut:"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">fx_name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>155</span> 
<span class='line'>156</span> 	</span><span class="NAME">bindToWindow</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>157</span> 		</span><span class="NAME">window.juggernaut</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>158</span> 		</span><span class="NAME">this.appendFlashObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>159</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>160</span> 
<span class='line'>161</span> 	</span><span class="NAME">toJSON</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">hash</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>162</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">Object.toJSON</span><span class="PUNC">(</span><span class="NAME">hash</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>163</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>164</span> 
<span class='line'>165</span> 	</span><span class="NAME">parseJSON</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">string</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>166</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">string.evalJSON</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>168</span> 
<span class='line'>169</span> 	</span><span class="NAME">swf</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>170</span> 		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">(</span><span class="NAME">this.options.swf_name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">    
<span class='line'>171</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>172</span> 
<span class='line'>173</span> 	</span><span class="NAME">appendElement</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>174</span> 		</span><span class="NAME">this.element</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Element</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'juggernaut'</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>175</span> 		</span><span class="NAME">$</span><span class="PUNC">(</span><span class="NAME">document.body</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">insert</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">bottom</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.element</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>176</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>177</span> 
<span class='line'>178</span> 	</span><span class="COMM">/*** END PROTOTYPE SPECIFIC ***/</span><span class="WHIT">
<span class='line'>179</span> 
<span class='line'>180</span> 	</span><span class="NAME">appendFlashObject</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>181</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this.swf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>182</span> 			</span><span class="KEYW">throw</span><span class="PUNC">(</span><span class="STRN">"Juggernaut error. 'swf_name' must be unique per juggernaut instance."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>183</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>184</span> 		</span><span class="NAME">this.appendElement</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> 		</span><span class="NAME">rio.swfobject.embedSWF</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>186</span> 			</span><span class="NAME">this.options.swf_address</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>187</span> 			</span><span class="STRN">'juggernaut'</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>188</span> 			</span><span class="NAME">this.options.width</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>189</span> 			</span><span class="NAME">this.options.height</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>190</span> 			</span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">this.options.flash_version</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>191</span> 			</span><span class="NAME">this.options.ei_swf_address</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>192</span> 			</span><span class="PUNC">{</span><span class="STRN">'bridgeName'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.options.bridge_name</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>193</span> 			</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>194</span> 			</span><span class="PUNC">{</span><span class="STRN">'id'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.options.swf_name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'name'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">this.options.swf_name</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>195</span> 		</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>196</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>197</span> 
<span class='line'>198</span> 	</span><span class="NAME">refreshFlashObject</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>199</span> 		</span><span class="NAME">this.swf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">remove</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> 		</span><span class="NAME">this.appendFlashObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>201</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>202</span> 
<span class='line'>203</span> 	</span><span class="NAME">errorConnecting</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>204</span> 		</span><span class="NAME">this.is_connected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>205</span> 		</span><span class="NAME">this.live.update</span><span class="PUNC">(</span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.attempting_to_reconnect</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>207</span> 			</span><span class="NAME">this.logger</span><span class="PUNC">(</span><span class="STRN">'There has been an error connecting'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>208</span> 			</span><span class="NAME">this.fire_event</span><span class="PUNC">(</span><span class="STRN">'errorConnecting'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>209</span> 			</span><span class="NAME">this.reconnect</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>210</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>211</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>212</span> 
<span class='line'>213</span> 	</span><span class="NAME">disconnected</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>214</span> 		</span><span class="NAME">this.is_connected</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span> 		</span><span class="NAME">this.live.update</span><span class="PUNC">(</span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.attempting_to_reconnect</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>217</span> 			</span><span class="NAME">this.logger</span><span class="PUNC">(</span><span class="STRN">'Connection has been lost'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> 			</span><span class="NAME">this.fire_event</span><span class="PUNC">(</span><span class="STRN">'disconnected'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>219</span> 			</span><span class="NAME">this.reconnect</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>221</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>222</span> 
<span class='line'>223</span> 	</span><span class="NAME">reconnect</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>224</span> 		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this.options.reconnect_attempts</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>225</span> 			</span><span class="NAME">this.attempting_to_reconnect</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>226</span> 			</span><span class="NAME">this.live.update</span><span class="PUNC">(</span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>227</span> 			</span><span class="NAME">this.fire_event</span><span class="PUNC">(</span><span class="STRN">'reconnect'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>228</span> 			</span><span class="NAME">this.logger</span><span class="PUNC">(</span><span class="STRN">'Will attempt to reconnect '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">this.options.reconnect_attempts</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' times,'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>229</span> 			</span><span class="STRN">'the first in '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.options.reconnect_intervals</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">' seconds'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>230</span> 			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">attemptReconnect</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>231</span> 				</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.is_connected</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>232</span> 					</span><span class="NAME">this.logger</span><span class="PUNC">(</span><span class="STRN">'Attempting reconnect'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>233</span> 					</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this.ever_been_connected</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>234</span> 						</span><span class="NAME">this.refreshFlashObject</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>235</span> 					</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>236</span> 						</span><span class="NAME">this.connect</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>237</span> 					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>238</span> 				</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>239</span> 			</span><span class="PUNC">}</span><span class="PUNC">.</span><span class="NAME">bind</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>240</span> 			</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">this.options.reconnect_attempts</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>241</span> 				</span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="NAME">attemptReconnect</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.options.reconnect_intervals</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">1000</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>242</span> 			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>243</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>244</span> 	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>245</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>246</span> 
<span class='line'>247</span> </span><span class="NAME">rio.Juggernaut.boot</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>248</span> 	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">push</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">rio.Juggernaut</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>249</span> 		</span><span class="NAME">ei_swf_address</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"/javascripts/lib/expressinstall.swf"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>250</span> 		</span><span class="NAME">reconnect_intervals</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>251</span> 		</span><span class="NAME">flash_version</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>252</span> 		</span><span class="NAME">channels</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>253</span> 		</span><span class="NAME">session_id</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">rio.environment.sessionId</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>254</span> 		</span><span class="NAME">client_id</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">rio.environment.userId</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">Math.round</span><span class="PUNC">(</span><span class="NAME">Math.random</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1000000000</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>255</span> 		</span><span class="NAME">host</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">rio.environment.pushUrl</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>256</span> 		</span><span class="NAME">width</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"0px"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>257</span> 		</span><span class="NAME">height</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"0px"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>258</span> 		</span><span class="NAME">flash_color</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"#fff"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>259</span> 		</span><span class="NAME">swf_name</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"juggernaut_flash"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>260</span> 		</span><span class="NAME">port</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">rio.environment.pushPort</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>261</span> 		</span><span class="NAME">bridge_name</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"juggernaut"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>262</span> 		</span><span class="NAME">debug</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">rio.environment.pushDebug</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>263</span> 		</span><span class="NAME">swf_address</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"/javascripts/lib/juggernaut.swf"</span><span class="PUNC">,</span><span class="WHIT"> 
<span class='line'>264</span> 		</span><span class="NAME">reconnect_attempts</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="WHIT">
<span class='line'>265</span> 	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>266</span> 
<span class='line'>267</span> 	</span><span class="NAME">setInterval</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>268</span> 		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">rio.push</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>269</span> 			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">rio.push.is_connected</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> 
<span class='line'>270</span> 				</span><span class="NAME">rio.push.connect</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> 			</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>272</span> 				</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Ajax.Request</span><span class="PUNC">(</span><span class="STRN">"/push/test_connection"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>273</span> 					</span><span class="NAME">method</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"get"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>274</span> 					</span><span class="NAME">asynchronous</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>275</span> 					</span><span class="NAME">evalJS</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>276</span> 					</span><span class="NAME">evalJSON</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>277</span> 					</span><span class="NAME">onSuccess</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">response</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>278</span> 						</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">response.responseText</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"CONNECTED"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>279</span> 							</span><span class="NAME">rio.warn</span><span class="PUNC">(</span><span class="STRN">"Juggernaut connection silently failed"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>280</span> 							</span><span class="NAME">rio.push.resetConnection</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> 						</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>282</span> 					</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>283</span> 				</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>284</span> 			</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>285</span> 		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>286</span> 	</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">60000</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>287</span> 
<span class='line'>288</span> 	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">push</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>289</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>290</span> 
<span class='line'>291</span> 
<span class='line'>292</span> 
<span class='line'>293</span> 
<span class='line'>294</span> 
<span class='line'>295</span> 
<span class='line'>296</span> </span></pre></body></html>